package com.tolbahady.android.game;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.*;

public class Game extends GameActivity {
	private PlayerslistAdapter pla;
	private ListView lv_players;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        lv_players = (ListView) findViewById(R.id.lv_players);//getting the list view
        pla = new PlayerslistAdapter(this, R.layout.player_row, players);//creating adapter
        lv_players.setAdapter(pla);
        
        ((Button)findViewById(R.id.btn_add_player)).setOnClickListener(new OnClickListener() {
//			@Override
			public void onClick(View v) {
				Intent newPlayer = new Intent(Game.this,NewPlayerActivity.class);
				startActivity(newPlayer);
			}
		});
        ((Button)findViewById(R.id.btnStartGame)).setOnClickListener(new OnClickListener() {
//			@Override
			public void onClick(View v) {
				if(TabelGame.startGame() == null) return;
				Intent newPlayer = new Intent(Game.this,GameControllerActivity.class);
				startActivity(newPlayer);
			}
		});
        
    }
    
    @Override
    protected void onStart() {
    	super.onStart();
    	updateList();
    }
    
    @Override
    protected void onResume() {
    	super.onResume();
    }
    
    @Override
    protected void onSaveInstanceState(Bundle outState) {
    	super.onSaveInstanceState(outState);
    	
    }
    
    public void updateList(){
    	pla.notifyDataSetChanged();
    }
}